using UnityEngine;

public class EnemyState_XiaoGuaGua_散步 : EnemyStateBase_XiaoGuaGua
{
	private Vector2 _targetPos;

	private Vector2 _StartPos;

	private Vector2 _DirSpeed;

	public override void OnEnter()
	{
		_Mono._Ani.Play("跳跃");
		_StartPos = _Mono.transform.position;
		if (_Mono._C_活动范围 != null)
		{
			_targetPos = _Mono._C_活动范围.F_得到范围内随机点();
		}
		else
		{
			Vector2 vector = Random.insideUnitCircle * 4f;
			vector.y /= 4f;
			_targetPos = _Mono._StartPos + vector;
		}
		_Mono.transform.localScale = new Vector3((_targetPos.x > _StartPos.x) ? 1 : (-1), 1f, 1f);
		_Timer = 0.3f;
		_DirSpeed = (_targetPos - _StartPos).normalized;
		_Mono._Rb2D.AddForce(30f * _DirSpeed, ForceMode2D.Impulse);
		_Mono._Tsf_移动目标.transform.position = _targetPos;
	}

	public override void OnExit()
	{
	}

	public override void OnUpdate()
	{
		_Timer -= Time.deltaTime;
		if (_Timer < 0f)
		{
			_Mono.ChangeState(StateType_Enemy_XiaoGuai.站立);
		}
	}
}
